package com.resou.reader.mine.coupon;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.resou.reader.R;
import com.resou.reader.base.ResouBaseActivity;
import com.resou.reader.mine.adapter.ViewPagerAdapter;
import com.resou.reader.mine.coupon.fragment.Fragment_pastDue;
import com.resou.reader.mine.coupon.fragment.Fragment_unused;
import com.resou.reader.mine.coupon.fragment.Fragment_useed;
import com.resou.reader.view.TabView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 我的优惠券
 */
public class CouponActivity extends ResouBaseActivity implements ICouponContract.ICouponView {
    private static final String TAG = "CouponActivity";
    @BindView(R.id.ivBack)
    ImageView ivBack;
    @BindView(R.id.tvTitle)
    TextView tvTitle;
    @BindView(R.id.mTabView)
    TabView mTabView;
    @BindView(R.id.mViewPager)
    ViewPager mViewPager;
    CouponPresenter couponPresenter;
    Fragment_unused fragment_unused;
    Fragment_useed fragment_useed;
    Fragment_pastDue fragment_pastDue;
    List<Fragment> fragmentList = null;
    ViewPagerAdapter viewPagerAdapter = null;

    public static void start(Context context) {
        Intent starter = new Intent(context, CouponActivity.class);
        context.startActivity(starter);
    }

    @Override
    protected void initStatusBar() {

    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_coupon;
    }

    @Override
    public void retryRefreshData() {

    }

    @Override
    protected void initPresenter() {
        couponPresenter = new CouponPresenter(this);
    }

    @Override
    protected void initView() {
        tvTitle.setText("我的热券");
        fragmentList = new ArrayList<>();
        fragment_unused = Fragment_unused.newInstance();
        fragment_useed = Fragment_useed.newInstance();
        fragment_pastDue = Fragment_pastDue.newInstance();
        fragmentList.add(fragment_unused);
        fragmentList.add(fragment_useed);
        fragmentList.add(fragment_pastDue);

        viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager(), fragmentList);
        mViewPager.setAdapter(viewPagerAdapter);

        mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int i, float v, int i1) {

            }

            @Override
            public void onPageSelected(int i) {
                mTabView.setPosition(i);
            }

            @Override
            public void onPageScrollStateChanged(int i) {

            }
        });

        mTabView.setTabViewOnclick(new TabView.TabViewOnclick() {
            @Override
            public void setTabViewPositionOnclickListener(int pos) {
                mViewPager.setCurrentItem(pos);
            }
        });
    }


    @OnClick(R.id.ivBack)
    public void onViewClicked() {
        finish();
    }

    @Override
    public void initData() {

    }

    @Override
    public void showContent() {

    }

    @Override
    public void showProgress() {
    }

    @Override
    public void showError(Throwable throwable) {

    }

    @Override
    public void showEmpty() {

    }

    @Override
    public void showHotTicketData() {
        Log.i(TAG, "quearHotTicketData: 获取数据");

    }
}
